/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ipostservices.services;

import ipostservices.model.bean.Postit;
import ipostservices.model.dao.PostitDAO;
import ipostservices.util.Constantes;
import java.util.List;

/**
 *
 * @author sixviv
 */
public class PostitSrv {
    private PostitDAO pDAO = new PostitDAO();

    public String guardar(Postit postit){
        if(pDAO.insertar(postit)){
            return Constantes.EXITO_STR;
        }
        else{
            return Constantes.ERROR_STR;
        }
    }

    public String editar(Postit postit){
        if(pDAO.actualizar(postit)){
            return Constantes.EXITO_STR;
        }
        else{
            return Constantes.ERROR_STR;
        }
    }

    public String eliminar(int idPosit){
        if(pDAO.borrar(pDAO.getById(idPosit))){
            return Constantes.EXITO_STR;
        }
        else{
            return Constantes.ERROR_STR;
        }
    }

    public Postit getPostit(int idPostit){
        return pDAO.getById(idPostit);
    }

    public List<Postit> getAllPostits(){
        return pDAO.getAll(Postit.class);
    }

    public List<Postit> getBySeccionCAndProy(int idSeccionC, int idProy){
        return pDAO.getBySeccionCAndProy(idProy, idSeccionC);
    }

}
